import { useModel } from "@supcon/supcon-microapp";
import { isDEV, PLATFORM_TYPE } from "./utils";

const usePlatform = () => {
  const masterProps = useModel("@@qiankunStateFromMaster");
  console.log("masterProps", masterProps);

  const getPlatform = () => {
    if (isDEV) {
      // dev // TODO: 调试后改为dev
      return PLATFORM_TYPE.dev;
    } else if (masterProps) {
      // obp
      return PLATFORM_TYPE.obp;
    } else {
      // supOS
      return PLATFORM_TYPE.supOS;
    }
  };

  let currentPlatform = getPlatform();
  // console.log('usePlatform currentPlatform', currentPlatform);
  return currentPlatform;
};

export default usePlatform;
